package com.itheima.chapter08.list;

import java.util.ArrayList;
import java.util.List;

//方法
public class demo2 {
    public static void main(String[] args) {
        List<String> list= new ArrayList<>();
        list.add("aa");
        list.add("bb");
        list.add("bb");
        System.out.println(list);
        add(list);

        list.set(1,"qq");
        System.out.println(list);
        String s = list.get(0);
        System.out.println(s);
        remove(list);

    }

    private static void remove(List<String> list) {
        list.remove(1);
        list.remove(2);
        System.out.println(list);
    }

    private static void add(List<String> list) {
        list.add(1,"cc");
        list.add(3,"dddd");
        //list.add(11,"dddd");
        //IndexOutOfBoundsException
        System.out.println(list);
    }
}
